
package com.shop.cloud.mall.api.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cloud.common.core.constant.CacheConstants;
import com.shop.cloud.mall.api.mapper.ActiveBackgroundMapper;
import com.shop.cloud.mall.api.service.ActiveBackgroundService;
import com.shop.cloud.mall.common.entity.ActiveBackground;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 活动背景
 *
 * @author
 * @date 2023-03-24 10:32:06
 */
@Service
public class ActiveBackgroundServiceImpl extends ServiceImpl<ActiveBackgroundMapper, ActiveBackground> implements ActiveBackgroundService {

    @Override
    @Cacheable(value = CacheConstants.MALL_ENABLE_ACTIVE_BACKGROUND, key = "'value'")
    public List<ActiveBackground> listEnableActiveBackground() {
        return baseMapper.selectList(Wrappers.<ActiveBackground>query().lambda()
                .eq(ActiveBackground::getEnable, Boolean.TRUE)
                .ge(ActiveBackground::getValidEndTime, LocalDateTime.now()));
    }
}
